package com.cy.pj.module.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.ArrayList;
import java.util.List;



@Controller
public class ModelAndViewController {
    @RequestMapping("/doModelAndView01")
    public String doModelAndView01(Model model){
        model.addAttribute("name","jsaon");
        model.addAttribute("state","ok");
        return "view";
    }
    @RequestMapping("/doModelAndView02")
    public ModelAndView doModleAndView02(ModelAndView mv){
        mv.addObject("name","jsaon");
        mv.addObject("state",true);
        mv.setViewName("view");
        return mv;
    }
    @RequestMapping("/doModelAndViewI03")
    public ModelAndView doModelAndViewI03(ModelAndView mv){
        List<String> list = new ArrayList<>();
        list.add("北京");
        list.add("上海");
        list.add("深圳");
        mv.addObject("citys",list);
        mv.setViewName("view");
        return mv;
    }
}
